<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>module GC - RDoc Documentation</title>


<script src="./js/navigation.js" defer></script>
<script src="./js/search.js" defer></script>
<script src="./js/search_index.js" defer></script>
<script src="./js/searcher.js" defer></script>
<script src="./js/darkfish.js" defer></script>

<script src="./js/jquery-3.2.0.min.js"></script>

<script src="./js/vue.min.js"></script>
<script src="./js/js.cookie.min.js"></script>

<link href="./css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="./css/rdoc.css" rel="stylesheet">
<link href="./css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "./";
  var index_rel_prefix = "./";
  var darkModeCsseHref = "./css/rdoc-dm.css"
  var defaultModeCssHref = "./css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="module">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0-preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="./index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="./table_of_contents.html#pages">Pages</a>
    <a href="./table_of_contents.html#classes">Classes</a>
    <a href="./table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
        
        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-add_stress_to_class">::add_stress_to_class</a>
    <li ><a href="#method-c-auto_compact">::auto_compact</a>
    <li ><a href="#method-c-auto_compact-3D">::auto_compact=</a>
    <li ><a href="#method-c-compact">::compact</a>
    <li ><a href="#method-c-count">::count</a>
    <li ><a href="#method-c-disable">::disable</a>
    <li ><a href="#method-c-enable">::enable</a>
    <li ><a href="#method-c-latest_compact_info">::latest_compact_info</a>
    <li ><a href="#method-c-latest_gc_info">::latest_gc_info</a>
    <li ><a href="#method-c-malloc_allocated_size">::malloc_allocated_size</a>
    <li ><a href="#method-c-malloc_allocations">::malloc_allocations</a>
    <li ><a href="#method-c-measure_total_time">::measure_total_time</a>
    <li ><a href="#method-c-measure_total_time-3D">::measure_total_time=</a>
    <li ><a href="#method-c-remove_stress_to_class">::remove_stress_to_class</a>
    <li ><a href="#method-c-start">::start</a>
    <li ><a href="#method-c-stat">::stat</a>
    <li ><a href="#method-c-stat_heap">::stat_heap</a>
    <li ><a href="#method-c-stress">::stress</a>
    <li ><a href="#method-c-stress-3D">::stress=</a>
    <li ><a href="#method-c-total_time">::total_time</a>
    <li ><a href="#method-c-verify_compaction_references">::verify_compaction_references</a>
    <li ><a href="#method-c-verify_internal_consistency">::verify_internal_consistency</a>
    <li ><a href="#method-i-garbage_collect">#garbage_collect</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="module-GC">
    <h1 id="module-GC" class="module">
      module GC
    </h1>

    <section class="description">
    
<p>The GC module provides an interface to Ruby’s mark and sweep garbage collection mechanism.</p>

<p>Some of the underlying methods are also available via the <a href="ObjectSpace.html"><code>ObjectSpace</code></a> module.</p>

<p>You may obtain information about the operation of the GC through <a href="GC/Profiler.html"><code>GC::Profiler</code></a>.</p>

    </section>

      <section id="5Buntitled-5D" class="documentation-section">


      <section class="constants-list">
      <header>
      <h3>Constants</h3>
      </header>
      <dl>
          <dt id="INTERNAL_CONSTANTS">INTERNAL_CONSTANTS
          <dd><p>Internal constants in the garbage collector.</p>
          <dt id="OPTS">OPTS
          <dd><p>GC build options</p>
        </dl>
        </section>



                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-add_stress_to_class" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          add_stress_to_class(class[, ...])
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Raises <a href="NoMemoryError.html"><code>NoMemoryError</code></a> when allocating an instance of the given classes.</p>

                              <div class="method-source-code" id="add_stress_to_class-source">
            <pre>static VALUE
rb_gcdebug_add_stress_to_class(int argc, VALUE *argv, VALUE self)
{
    rb_objspace_t *objspace = &amp;rb_objspace;

    if (!stress_to_class) {
        set_stress_to_class(rb_ary_hidden_new(argc));
    }
    rb_ary_cat(stress_to_class, argv, argc);
    return self;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-auto_compact" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          auto_compact    &rarr; true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns whether or not automatic compaction has been enabled.</p>

                              <div class="method-source-code" id="auto_compact-source">
            <pre>static VALUE
gc_get_auto_compact(VALUE _)
{
    return RBOOL(ruby_enable_autocompact);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-auto_compact-3D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          auto_compact = flag
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Updates automatic compaction mode.</p>

<p>When enabled, the compactor will execute on every major collection.</p>

<p>Enabling compaction will degrade performance on major collections.</p>

                              <div class="method-source-code" id="auto_compact-3D-source">
            <pre>static VALUE
gc_set_auto_compact(VALUE _, VALUE v)
{
    GC_ASSERT(GC_COMPACTION_SUPPORTED);

    ruby_enable_autocompact = RTEST(v);
    return v;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-compact" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          compact
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>This function compacts objects together in Ruby’s heap.  It eliminates unused space (or fragmentation) in the heap by moving objects in to that unused space.  This function returns a hash which contains statistics about which objects were moved.  See <code>GC.latest_gc_info</code> for details about compaction statistics.</p>

<p>This method is implementation specific and not expected to be implemented in any implementation besides MRI.</p>

<p>To test whether GC compaction is supported, use the idiom:</p>

<pre class="ruby"><span class="ruby-constant">GC</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:compact</span>)
</pre>

                              <div class="method-source-code" id="compact-source">
            <pre>static VALUE
gc_compact(VALUE self)
{
    /* Run GC with compaction enabled */
    gc_start_internal(NULL, self, Qtrue, Qtrue, Qtrue, Qtrue);

    return gc_compact_stats(self);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-count" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          count &rarr; Integer
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>The number of times GC occurred.</p>

<p>It returns the number of times GC occurred since the process started.</p>

                              <div class="method-source-code" id="count-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/gc.rb, line 104</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">count</span>
  <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">gc_count</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-disable" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          disable    &rarr; true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Disables garbage collection, returning <code>true</code> if garbage collection was already disabled.</p>

<pre class="ruby"><span class="ruby-constant">GC</span>.<span class="ruby-identifier">disable</span>   <span class="ruby-comment">#=&gt; false</span>
<span class="ruby-constant">GC</span>.<span class="ruby-identifier">disable</span>   <span class="ruby-comment">#=&gt; true</span>
</pre>

                              <div class="method-source-code" id="disable-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/gc.rb, line 68</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">disable</span>
  <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">gc_disable</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-enable" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          enable    &rarr; true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Enables garbage collection, returning <code>true</code> if garbage collection was previously disabled.</p>

<pre class="ruby"><span class="ruby-constant">GC</span>.<span class="ruby-identifier">disable</span>   <span class="ruby-comment">#=&gt; false</span>
<span class="ruby-constant">GC</span>.<span class="ruby-identifier">enable</span>    <span class="ruby-comment">#=&gt; true</span>
<span class="ruby-constant">GC</span>.<span class="ruby-identifier">enable</span>    <span class="ruby-comment">#=&gt; false</span>
</pre>

                              <div class="method-source-code" id="enable-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/gc.rb, line 56</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">enable</span>
  <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">gc_enable</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-latest_compact_info" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          latest_compact_info &rarr; hash
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns information about object moved in the most recent GC compaction.</p>

<p>The returned hash has two keys :considered and :moved.  The hash for :considered lists the number of objects that were considered for movement by the compactor, and the :moved hash lists the number of objects that were actually moved.  Some objects can’t be moved (maybe they were pinned) so these numbers can be used to calculate compaction efficiency.</p>

                              <div class="method-source-code" id="latest_compact_info-source">
            <pre>static VALUE
gc_compact_stats(VALUE self)
{
    size_t i;
    rb_objspace_t *objspace = &amp;rb_objspace;
    VALUE h = rb_hash_new();
    VALUE considered = rb_hash_new();
    VALUE moved = rb_hash_new();
    VALUE moved_up = rb_hash_new();
    VALUE moved_down = rb_hash_new();

    for (i=0; i&lt;T_MASK; i++) {
        if (objspace-&gt;rcompactor.considered_count_table[i]) {
            rb_hash_aset(considered, type_sym(i), SIZET2NUM(objspace-&gt;rcompactor.considered_count_table[i]));
        }

        if (objspace-&gt;rcompactor.moved_count_table[i]) {
            rb_hash_aset(moved, type_sym(i), SIZET2NUM(objspace-&gt;rcompactor.moved_count_table[i]));
        }

        if (objspace-&gt;rcompactor.moved_up_count_table[i]) {
            rb_hash_aset(moved_up, type_sym(i), SIZET2NUM(objspace-&gt;rcompactor.moved_up_count_table[i]));
        }

        if (objspace-&gt;rcompactor.moved_down_count_table[i]) {
            rb_hash_aset(moved_down, type_sym(i), SIZET2NUM(objspace-&gt;rcompactor.moved_down_count_table[i]));
        }
    }

    rb_hash_aset(h, ID2SYM(rb_intern(&quot;considered&quot;)), considered);
    rb_hash_aset(h, ID2SYM(rb_intern(&quot;moved&quot;)), moved);
    rb_hash_aset(h, ID2SYM(rb_intern(&quot;moved_up&quot;)), moved_up);
    rb_hash_aset(h, ID2SYM(rb_intern(&quot;moved_down&quot;)), moved_down);

    return h;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-latest_gc_info" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          latest_gc_info &rarr; hash
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          latest_gc_info(hash) &rarr; hash
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          latest_gc_info(:major_by) &rarr; :malloc
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Returns information about the most recent garbage collection.</p>

<p>If the optional argument, hash, is given, it is overwritten and returned. This is intended to avoid probe effect.</p>

                              <div class="method-source-code" id="latest_gc_info-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/gc.rb, line 265</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">latest_gc_info</span> <span class="ruby-identifier">hash_or_key</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">gc_latest_gc_info</span> <span class="ruby-identifier">hash_or_key</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-malloc_allocated_size" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          malloc_allocated_size &rarr; Integer
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the size of memory allocated by malloc().</p>

<p>Only available if ruby was built with <code>CALC_EXACT_MALLOC_SIZE</code>.</p>

                              <div class="method-source-code" id="malloc_allocated_size-source">
            <pre>static VALUE
gc_malloc_allocated_size(VALUE self)
{
    return UINT2NUM(rb_objspace.malloc_params.allocated_size);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-malloc_allocations" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          malloc_allocations &rarr; Integer
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the number of malloc() allocations.</p>

<p>Only available if ruby was built with <code>CALC_EXACT_MALLOC_SIZE</code>.</p>

                              <div class="method-source-code" id="malloc_allocations-source">
            <pre>static VALUE
gc_malloc_allocations(VALUE self)
{
    return UINT2NUM(rb_objspace.malloc_params.allocations);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-measure_total_time" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          measure_total_time &rarr; true/false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Return <a href="GC.html#method-c-measure_total_time"><code>measure_total_time</code></a> flag (default: <code>true</code>). Note that measurement can affect the application performance.</p>

                              <div class="method-source-code" id="measure_total_time-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/gc.rb, line 307</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">measure_total_time</span>
  <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">cexpr!</span> <span class="ruby-string">%{
    RBOOL(rb_objspace.flags.measure_gc)
  }</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-measure_total_time-3D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          measure_total_time = true/false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Enable to measure GC time. You can get the result with <code>GC.stat(:time)</code>. Note that GC time measurement can cause some performance overhead.</p>

                              <div class="method-source-code" id="measure_total_time-3D-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/gc.rb, line 295</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">measure_total_time=</span>(<span class="ruby-identifier">flag</span>)
  <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">cstmt!</span> <span class="ruby-string">%{
    rb_objspace.flags.measure_gc = RTEST(flag) ? TRUE : FALSE;
    return flag;
  }</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-remove_stress_to_class" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          remove_stress_to_class(class[, ...])
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>No longer raises <a href="NoMemoryError.html"><code>NoMemoryError</code></a> when allocating an instance of the given classes.</p>

                              <div class="method-source-code" id="remove_stress_to_class-source">
            <pre>static VALUE
rb_gcdebug_remove_stress_to_class(int argc, VALUE *argv, VALUE self)
{
    rb_objspace_t *objspace = &amp;rb_objspace;
    int i;

    if (stress_to_class) {
        for (i = 0; i &lt; argc; ++i) {
            rb_ary_delete_same(stress_to_class, argv[i]);
        }
        if (RARRAY_LEN(stress_to_class) == 0) {
            set_stress_to_class(0);
        }
    }
    return Qnil;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-start" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">start</span><span
                                class="method-args">(full_mark: true, immediate_mark: true, immediate_sweep: true)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Initiates garbage collection, even if manually disabled.</p>

<p>The <code>full_mark</code> keyword argument determines whether or not to perform a major garbage collection cycle. When set to <code>true</code>, a major garbage collection cycle is ran, meaning all objects are marked. When set to <code>false</code>, a minor garbage collection cycle is ran, meaning only young objects are marked.</p>

<p>The <code>immediate_mark</code> keyword argument determines whether or not to perform incremental marking. When set to <code>true</code>, marking is completed during the call to this method. When set to <code>false</code>, marking is performed in steps that is interleaved with future Ruby code execution, so marking might not be completed during this method call. Note that if <code>full_mark</code> is <code>false</code> then marking will always be immediate, regardless of the value of <code>immediate_mark</code>.</p>

<p>The <code>immedate_sweep</code> keyword argument determines whether or not to defer sweeping (using lazy sweep). When set to <code>true</code>, sweeping is performed in steps that is interleaved with future Ruby code execution, so sweeping might not be completed during this method call. When set to <code>false</code>, sweeping is completed during the call to this method.</p>

<p>Note: These keyword arguments are implementation and version dependent. They are not guaranteed to be future-compatible, and may be ignored if the underlying implementation does not support them.</p>

                              <div class="method-source-code" id="start-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/gc.rb, line 38</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">start</span> <span class="ruby-value">full_mark:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">immediate_mark:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">immediate_sweep:</span> <span class="ruby-keyword">true</span>
  <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">gc_start_internal</span> <span class="ruby-identifier">full_mark</span>, <span class="ruby-identifier">immediate_mark</span>, <span class="ruby-identifier">immediate_sweep</span>, <span class="ruby-keyword">false</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-stat" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          stat &rarr; Hash
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          stat(hash) &rarr; Hash
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          stat(:key) &rarr; Numeric
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Returns a <a href="Hash.html"><code>Hash</code></a> containing information about the GC.</p>

<p>The contents of the hash are implementation specific and may change in the future without notice.</p>

<p>The hash includes information about internal statistics about GC such as:</p>
<dl class="rdoc-list label-list"><dt>count
<dd>
<p>The total number of garbage collections ran since application start (count includes both minor and major garbage collections)</p>
</dd><dt>time
<dd>
<p>The total time spent in garbage collections (in milliseconds)</p>
</dd><dt>heap_allocated_pages
<dd>
<p>The total number of <code>:heap_eden_pages</code> + <code>:heap_tomb_pages</code></p>
</dd><dt>heap_sorted_length
<dd>
<p>The number of pages that can fit into the buffer that holds references to all pages</p>
</dd><dt>heap_allocatable_pages
<dd>
<p>The total number of pages the application could allocate without additional GC</p>
</dd><dt>heap_available_slots
<dd>
<p>The total number of slots in all <code>:heap_allocated_pages</code></p>
</dd><dt>heap_live_slots
<dd>
<p>The total number of slots which contain live objects</p>
</dd><dt>heap_free_slots
<dd>
<p>The total number of slots which do not contain live objects</p>
</dd><dt>heap_final_slots
<dd>
<p>The total number of slots with pending finalizers to be run</p>
</dd><dt>heap_marked_slots
<dd>
<p>The total number of objects marked in the last GC</p>
</dd><dt>heap_eden_pages
<dd>
<p>The total number of pages which contain at least one live slot</p>
</dd><dt>heap_tomb_pages
<dd>
<p>The total number of pages which do not contain any live slots</p>
</dd><dt>total_allocated_pages
<dd>
<p>The cumulative number of pages allocated since application start</p>
</dd><dt>total_freed_pages
<dd>
<p>The cumulative number of pages freed since application start</p>
</dd><dt>total_allocated_objects
<dd>
<p>The cumulative number of objects allocated since application start</p>
</dd><dt>total_freed_objects
<dd>
<p>The cumulative number of objects freed since application start</p>
</dd><dt>malloc_increase_bytes
<dd>
<p>Amount of memory allocated on the heap for objects. Decreased by any GC</p>
</dd><dt>malloc_increase_bytes_limit
<dd>
<p>When <code>:malloc_increase_bytes</code> crosses this limit, GC is triggered</p>
</dd><dt>minor_gc_count
<dd>
<p>The total number of minor garbage collections run since process start</p>
</dd><dt>major_gc_count
<dd>
<p>The total number of major garbage collections run since process start</p>
</dd><dt>compact_count
<dd>
<p>The total number of compactions run since process start</p>
</dd><dt>read_barrier_faults
<dd>
<p>The total number of times the read barrier was triggered during compaction</p>
</dd><dt>total_moved_objects
<dd>
<p>The total number of objects compaction has moved</p>
</dd><dt>remembered_wb_unprotected_objects
<dd>
<p>The total number of objects without write barriers</p>
</dd><dt>remembered_wb_unprotected_objects_limit
<dd>
<p>When <code>:remembered_wb_unprotected_objects</code> crosses this limit, major GC is triggered</p>
</dd><dt>old_objects
<dd>
<p>Number of live, old objects which have survived at least 3 garbage collections</p>
</dd><dt>old_objects_limit
<dd>
<p>When <code>:old_objects</code> crosses this limit, major GC is triggered</p>
</dd><dt>oldmalloc_increase_bytes
<dd>
<p>Amount of memory allocated on the heap for objects. Decreased by major GC</p>
</dd><dt>oldmalloc_increase_bytes_limit
<dd>
<p>When <code>:old_malloc_increase_bytes</code> crosses this limit, major GC is triggered</p>
</dd></dl>

<p>If the optional argument, hash, is given, it is overwritten and returned. This is intended to avoid probe effect.</p>

<p>This method is only expected to work on CRuby.</p>

                              <div class="method-source-code" id="stat-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/gc.rb, line 188</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">stat</span> <span class="ruby-identifier">hash_or_key</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">gc_stat</span> <span class="ruby-identifier">hash_or_key</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-stat_heap" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          stat_heap &rarr; Hash
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          stat_heap(nil, hash) &rarr; Hash
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          stat_heap(heap_name) &rarr; Hash
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          stat_heap(heap_name, hash) &rarr; Hash
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          stat_heap(heap_name, :key) &rarr; Numeric
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Returns information for heaps in the GC.</p>

<p>If the first optional argument, <code>heap_name</code>, is passed in and not <code>nil</code>, it returns a <code>Hash</code> containing information about the particular heap. Otherwise, it will return a <code>Hash</code> with heap names as keys and a <code>Hash</code> containing information about the heap as values.</p>

<p>If the second optional argument, <code>hash_or_key</code>, is given as <code>Hash</code>, it will be overwritten and returned. This is intended to avoid the probe effect.</p>

<p>If both optional arguments are passed in and the second optional argument is a symbol, it will return a <code>Numeric</code> of the value for the particular heap.</p>

<p>On CRuby, <code>heap_name</code> is of the type <code>Integer</code> but may be of type <code>String</code> on other implementations.</p>

<p>The contents of the hash are implementation specific and may change in the future without notice.</p>

<p>If the optional argument, hash, is given, it is overwritten and returned.</p>

<p>This method is only expected to work on CRuby.</p>

<p>The hash includes the following keys about the internal information in the GC:</p>
<dl class="rdoc-list label-list"><dt>slot_size
<dd>
<p>The slot size of the heap in bytes.</p>
</dd><dt>heap_allocatable_pages
<dd>
<p>The number of pages that can be allocated without triggering a new garbage collection cycle.</p>
</dd><dt>heap_eden_pages
<dd>
<p>The number of pages in the eden heap.</p>
</dd><dt>heap_eden_slots
<dd>
<p>The total number of slots in all of the pages in the eden heap.</p>
</dd><dt>heap_tomb_pages
<dd>
<p>The number of pages in the tomb heap. The tomb heap only contains pages that do not have any live objects.</p>
</dd><dt>heap_tomb_slots
<dd>
<p>The total number of slots in all of the pages in the tomb heap.</p>
</dd><dt>total_allocated_pages
<dd>
<p>The total number of pages that have been allocated in the heap.</p>
</dd><dt>total_freed_pages
<dd>
<p>The total number of pages that have been freed and released back to the system in the heap.</p>
</dd><dt>force_major_gc_count
<dd>
<p>The number of times major garbage collection cycles this heap has forced to start due to running out of free slots.</p>
</dd><dt>force_incremental_marking_finish_count
<dd>
<p>The number of times this heap has forced incremental marking to complete due to running out of pooled slots.</p>
</dd></dl>

                              <div class="method-source-code" id="stat_heap-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/gc.rb, line 251</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">stat_heap</span> <span class="ruby-identifier">heap_name</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">hash_or_key</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">gc_stat_heap</span> <span class="ruby-identifier">heap_name</span>, <span class="ruby-identifier">hash_or_key</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-stress" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          stress            &rarr; integer, true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns current status of GC stress mode.</p>

                              <div class="method-source-code" id="stress-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/gc.rb, line 76</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">stress</span>
  <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">gc_stress_get</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-stress-3D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          stress = flag          &rarr; flag
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Updates the GC stress mode.</p>

<p>When stress mode is enabled, the GC is invoked at every GC opportunity: all memory and object allocations.</p>

<p>Enabling stress mode will degrade performance, it is only for debugging.</p>

<p>flag can be true, false, or an integer bit-ORed following flags.</p>

<pre class="ruby"><span class="ruby-value">0x01</span><span class="ruby-operator">::</span> <span class="ruby-identifier">no</span> <span class="ruby-identifier">major</span> <span class="ruby-constant">GC</span>
<span class="ruby-value">0x02</span><span class="ruby-operator">::</span> <span class="ruby-identifier">no</span> <span class="ruby-identifier">immediate</span> <span class="ruby-identifier">sweep</span>
<span class="ruby-value">0x04</span><span class="ruby-operator">::</span> <span class="ruby-identifier">full</span> <span class="ruby-identifier">mark</span> <span class="ruby-identifier">after</span> <span class="ruby-identifier">malloc</span><span class="ruby-operator">/</span><span class="ruby-identifier">calloc</span><span class="ruby-operator">/</span><span class="ruby-identifier">realloc</span>
</pre>

                              <div class="method-source-code" id="stress-3D-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/gc.rb, line 94</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">stress=</span>(<span class="ruby-identifier">flag</span>)
  <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">gc_stress_set_m</span> <span class="ruby-identifier">flag</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-total_time" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          total_time &rarr; int
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Return measured GC total time in nano seconds.</p>

                              <div class="method-source-code" id="total_time-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/gc.rb, line 317</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">total_time</span>
  <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">cexpr!</span> <span class="ruby-string">%{
    ULL2NUM(rb_objspace.profile.marking_time_ns + rb_objspace.profile.sweeping_time_ns)
  }</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-verify_compaction_references" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          verify_compaction_references(toward: nil, double_heap: false) &rarr; hash
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Verify compaction reference consistency.</p>

<p>This method is implementation specific.  During compaction, objects that were moved are replaced with T_MOVED objects.  No object should have a reference to a T_MOVED object after compaction.</p>

<p>This function expands the heap to ensure room to move all objects, compacts the heap to make sure everything moves, updates all references, then performs a full GC.  If any object contains a reference to a T_MOVED object, that object should be pushed on the mark stack, and will make a SEGV.</p>

                              <div class="method-source-code" id="verify_compaction_references-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/gc.rb, line 284</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">verify_compaction_references</span>(<span class="ruby-value">toward:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">double_heap:</span> <span class="ruby-keyword">false</span>, <span class="ruby-value">expand_heap:</span> <span class="ruby-keyword">false</span>)
  <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">gc_verify_compaction_references</span>(<span class="ruby-identifier">double_heap</span>, <span class="ruby-identifier">expand_heap</span>, <span class="ruby-identifier">toward</span> <span class="ruby-operator">==</span> <span class="ruby-value">:empty</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-verify_internal_consistency" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          verify_internal_consistency                  &rarr; nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Verify internal consistency.</p>

<p>This method is implementation specific. Now this method checks generational consistency if RGenGC is supported.</p>

                              <div class="method-source-code" id="verify_internal_consistency-source">
            <pre>static VALUE
gc_verify_internal_consistency_m(VALUE dummy)
{
    gc_verify_internal_consistency(&amp;rb_objspace);
    return Qnil;
}</pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-garbage_collect" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">garbage_collect</span><span
                                class="method-args">(full_mark: true, immediate_mark: true, immediate_sweep: true)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="garbage_collect-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/gc.rb, line 42</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">garbage_collect</span> <span class="ruby-value">full_mark:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">immediate_mark:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">immediate_sweep:</span> <span class="ruby-keyword">true</span>
  <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">gc_start_internal</span> <span class="ruby-identifier">full_mark</span>, <span class="ruby-identifier">immediate_mark</span>, <span class="ruby-identifier">immediate_sweep</span>, <span class="ruby-keyword">false</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>. </p><p><a href="https://jamesbritt.bandcamp.com/">Hack your world.  Feed your head.  Live curious</a>.</p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

